home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3296 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: news.uiowa.edu!usenet
  2. From: larued@crpl.cedar-rapids.lib.ia@crpl.cedar-rapids.lib.ia.us
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: who know how to use large array in c++?
  5. Date: 23 Jan 1996 08:10:13 GMT
  6. Organization: University of Iowa, Iowa City, IA, USA
  7. Distribution: world
  8. Message-ID: <4e2555$ro6@flood.weeg.uiowa.edu>
  9. References: <4e0ml0$jt5@mercury.wright.edu>
  10. Reply-To: larued@crpl.cedar-rapids.lib.ia@crpl.cedar-rapids.lib.ia.us
  11. NNTP-Posting-Host: ppp-101.cedar-rapids.lib.ia.us
  12. X-Newsreader: IBM NewsReader/2 v1.9d - NLS
  13.  
  14. In <4e0ml0$jt5@mercury.wright.edu>, Apichart Intarapanich <aintara> writes:
  15. >hi
  16. >anybody know how can i declare array like this
  17. >
  18. >float a[1000][1000][1000];
  19. >
  20. >i cannot do that. i got segmentation fault statement. who know what should i
  21. >do?
  22. >apichart
  23. >
  24.  
  25.   Apichart,
  26.  
  27.   This is a problem related to system architecture and limitations of your
  28. compiler.
  29.  
  30.   Think about what you are asking the computer to do.
  31. What is 1000 * 1000 * 1000 * sizeof (float)?  My guess would be 4GB.
  32.  
  33.   This compiles just fine on my IBM C Set/2 (OS/2) machine.  It does not on
  34. a DOS machine because their is a 64KB limit to any specific structure.  This
  35. does not mean that OS/2 runs such an application.  No matter how I write 
  36. such a program, it will attempt to allocate a 4GB stack.  That won't happen
  37. on my 5.5GB system, whose swapper cannot exceed my partition size of 1GB.
  38.  
  39.   You could allocate several large files and create accessors to the files
  40. to simulate such a large structure.  My guess is that their is a better
  41. way of structuring your problem so that it does not use such a large array.
  42.  
  43.   Hope this helps,
  44.  
  45.     Dave LaRue
  46.